package com.example.wenqujingdian.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.wenqujingdian.R;
import com.example.wenqujingdian.model.LocalBookBean;
import com.vise.utils.assist.StringUtil;

import java.util.List;

/**
 * Created by 29083 on 2018/3/28.
 */

public class LocalBookClassListAdapter extends BaseQuickAdapter<LocalBookBean, BaseViewHolder> {

    private Context context;
    private String path,netWork;

    public LocalBookClassListAdapter(Context context, @Nullable List<LocalBookBean> data,String path,String netWork) {
        super(R.layout.item_book_list2, data);
        this.context = context;
        this.path = path;
        this.netWork=netWork;
    }

    @Override
    protected void convert(BaseViewHolder helper, LocalBookBean item) {
        if(!TextUtils.isEmpty(netWork)){
            Glide.with(context)
                    .load(item.getCover())
                    .error(R.mipmap.ic_default_image)
                    .placeholder(R.mipmap.ic_default_image)
                    .into((ImageView) helper.getView(R.id.image));
        }else {
            Glide.with(context)
                    .load(path + item.getCover())
                    .error(R.mipmap.ic_default_image)
                    .placeholder(R.mipmap.ic_default_image)
                    .into((ImageView) helper.getView(R.id.image));
        }


        //helper.addOnClickListener(R.id.btn_start_read);
        helper.setText(R.id.book_name, item.getBookTitle());
                /*.setText(R.id.author, "作者：" + item.author)*/

    }
}

